<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Spinatiev Ivan
 * Date: 11/6/12
 * Time: 11:54 AM
 * To change this template use File | Settings | File Templates.
 */
class Db_Products_Amounts extends Common {
    protected static $tableName = TAB_AMOUNTS;
    protected static $dbFields = array(
        'id',
        'am_amount',
        'am_is_sample',
        'am_is_default',
        'deleted'
    );

    /**
     * @var Db_Products_Amounts
     */
    public $objectArray;

    public $id;
    public $am_amount;
    public $am_is_sample;
    public $am_is_default;
    public $deleted;

    function __construct($value=NULL, $fieldName=NULL) {
        parent::__construct($value, $fieldName);
    }

    public static function removeDefaultAmount() {
        $sql = "UPDATE ?f SET `am_is_default` = 0 WHERE `am_is_default` = 1;";
        return self::$DB->q($sql, self::$tableName);
    }
}